//============================================================================
// Copyright (C) 2003-2013 Brett R. Jones 
// All Rights Reserved
//
// You may redistribute and/or modify for non commercial and commercial uses 
// provided this copyright notice remains in place and is not modified
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// brettjones1900@gmail.com
// http://www.p2panarchy.com
//============================================================================

#define PKT_LOGIN_STATE_ACCEPTED					0
#define PKT_LOGIN_STATE_INSUFFICIENT_PERMISSION		101
#define PKT_LOGIN_STATE_BLOCKED						102
#define PKT_LOGIN_STATE_BUSY						103
#define PKT_LOGIN_STATE_NEED_UPGRADE				104 //client needs version upgrade
#define PKT_LOGIN_STATE_BAD_PWD						105 // password invalid


class PktLoginReply : public VxPktHdr
{
public:
	PktLoginReply()
	{
		memset( this, 0, sizeof( PktLoginReply ) );
		m_u16PktLen = sizeof( PktLoginReply );
		m_u16PktType = PKT_TYPE_LOGIN_REPLY;
		u32Version = 0x01000000;
		u32LoginState = PKT_LOGIN_STATE_BLOCKED;
	}
	void CalcLen( int iCharCnt )
	{
		u8AvatarCnt = (U8) iCharCnt;
		//calculate length of packet from number chars in account
		m_u16PktLen = (unsigned short)ROUND_TO_16BYTE_BOUNDRY( sizeof( PktLoginReply ) - (PKT_MAX_AVATARS_PER_PLAYER - iCharCnt) * (PKT_MAX_AVATAR_NAME_LEN + 1) );
	}
	U8		u8AvatarCnt; // number of characters in account
	U8		au8Res[1]; //res to round to 16 bytes
	U32		u32Version; 
	U32		u32LoginState;
	U32		u32Res1;		// reserved
	U32		au32AvatarIds[ PKT_MAX_AVATARS_PER_PLAYER ];
	char	atcAvatarNames[ PKT_MAX_AVATARS_PER_PLAYER ][ PKT_MAX_AVATAR_NAME_LEN + 1 ];
};

